<?php
$this->breadcrumbs=array();

$this->sidebarTop = array(
    'label' => Yii::t('BackEnd', "Settings"),
    'link' => "#"
);
$this->moduleName = "menu";
$this->menu=array(
	array('label'=>Common::icon('delete'), 'itemOptions'=>array('style'=>'cursor:pointer', 'onclick'=>'Chienlv.deleteAll("form-admin", "/menu/deleteAll");return false;')),
	array('label'=>Common::icon('create'), 'url'=>array('create')),
);

$this->slidebar = Backend::getModuleSlideBar('Setting', '/menu/admin');

Yii::app()->clientScript->registerScript('search', "
    $('.search-button').click(function(){
        $('.search-form').toggle();
        return false;
    });
    $('.search-form form').submit(function(){
        $.fn.yiiGridView.update('menu-grid', {
            data: $(this).serialize()
        });
        return false;
    });
");

$this->title = Common::icon('manager'). Yii::t('BackEnd',"menu");
?>

<div class="search-form">
<?php $this->renderPartial('_search',array(
    'model'=>$model,
)); ?>
</div>

<!--Use for ajax link-->
<?php echo CHtml::beginForm('#', 'post', array('id'=>'form-admin', 'name'=>'frmAdmin')); ?>

<input type="hidden" id="moduleName" value="menu"/>

<?php $this->widget('application.widgets.admin.GridView', array(
    'id'=>'menu-grid',
    'dataProvider'=>$model->search(),
    'columns'=>array(
        'id',
        array(
            'name' => 'name',
            'htmlOptions' => array('style'=>'text-align: left;'),
        ),
        array(
            'name' => 'type',
            'value' => 'Menu::model()->getTypeLabel($data->type)',
            'htmlOptions' => array('style'=>'text-align: left;'),
        ),
        array(
            'name' => 'status',
            'header' => Yii::t('BackEnd', 'Status'),
            'type' => 'raw',
            'value' => '($data->status == Menu::STATUS_ENABLED)?CHtml::image(Yii::app()->request->baseUrl."/css/admin/images/tick.png", "enabled", array("class"=>"icon-status", "name"=>$data->id)):CHtml::image(Yii::app()->request->baseUrl."/css/admin/images/publish_x.png", "disabled", array("class"=>"icon-status", "name"=>$data->id))',
            'htmlOptions' => array('style'=>'text-align: center;'),
        ),
        array(
            'type'=>'raw',
            'value'=>'CHtml::hiddenField("ids[]", $data->id, array("id"=>"item-".$data->id)).CHtml::textField("sorder[]", $data->sorder, array("id"=>"sorder-".$data->id, "size"=>"4", "class"=>"numbersOnly"));',
            'name'=>'sorder',
            'header'=>Yii::t('BackEnd', 'Sort order').' '.CHtml::image(Yii::app()->request->baseUrl.'/css/admin/images/save.png', 'icon-save', array('style'=>'vertical-align: middle;cursor:pointer;', 'onclick'=>'javascript: $(this).parent().click(function(){return false;});document.frmAdmin.submit();return false;')),
            'htmlOptions'=>array('style'=>'text-align:center'),
        ),
        array(
            'header' => Yii::t('BackEnd', 'Menu items'),
            'type' => 'html',
            'value' => 'CHtml::link(Yii::t(\'BackEnd\', \'List items\'), Yii::app()->createUrl("/menuItem/admin", array("mId"=>$data->id)))',
            'htmlOptions' => array('style'=>'text-align: center;'),
        ),
        array(
            'class'=>'CButtonColumn',
            'deleteConfirmation'=>Yii::t('BackEnd', 'Are you sure you want to delete this item?'),
            'header'=> Yii::t('BackEnd', 'Actions'),
            'viewButtonImageUrl'=> Yii::app()->request->baseUrl.'/css/admin/images/page-view.png',
            'updateButtonImageUrl'=> Yii::app()->request->baseUrl.'/css/admin/images/page-edit.png',
            'deleteButtonImageUrl'=> Yii::app()->request->baseUrl.'/css/admin/images/page-delete.png'
        ),
    ),
)); ?>
<?php echo CHtml::endForm(); ?>